/*
 * Simple default handler.
 * M. J. Hawley
 * mike@media-lab.mit.edu
 * Copyright (c) November 1991, MIT Media Laboratory.
 */
#import "DefaultHandler.h"

extern id NXApp;

@implementation DefaultHandler

#define appname [NXApp appName]

char TmpDir[1024] = "/tmp";
char ArchiveFormat[1024] = ".tar.Z";
char FirstUsed[1024] = "";

static NXDefaultsVector OpenerDefaults = {
    {"TmpDir",  TmpDir},
    {"ArchiveFormat",  ArchiveFormat},
    {"FirstUsed",  FirstUsed},
    {NULL}
};

char *
deflt(char *s){
    return (char *)NXGetDefaultValue(appname,s);
}

+ loadDefaults {
    char *s;
#define l(x,xs) s = deflt(xs); if (s && *s) strcpy(x,s)
    l(TmpDir,"TmpDir");
    l(ArchiveFormat,"ArchiveFormat");
    l(FirstUsed,"FirstUsed");
    return self;
}

+ initialize {
    NXRegisterDefaults(appname, OpenerDefaults);
    [self loadDefaults];
    return self;
}

- writeDefaults:sender {
    NXWriteDefaults(appname, OpenerDefaults);
    return self;
}

- free {
    [self writeDefaults:self];
    [super free];
    return self;
}
@end
